import {Component, OnInit} from "@angular/core";
import {NavigationEnd, NavigationStart, Router} from "@angular/router";
import 'rxjs/add/operator/filter'

@Component({
  selector: 'app-content',
  templateUrl: './content.component.html',
  styleUrls: ['./content.component.css']
})
export class ContentComponent implements OnInit {
  PageTitle: string = '';
  PageDesc: string = '';
  constructor(public route: Router) {
    // route.events.filter(event => event instanceof  NavigationEnd)
    //   .subscribe((event: NavigationEnd ) => {
    //     if ( event.url == '/dashboard') {
    //       this.PageTitle = '这里是首页';
    //     }else if (event.url == '/stock') {
    //       this.PageTitle = '这里是列表页面';
    //     }
    //   });
    route.events.filter(event => event instanceof  NavigationStart)
      .subscribe((event: NavigationStart ) => {
        if ( event.url == '/dashboard'|| event.url == '/') {
          this.PageTitle = '这里是首页';
        }else if (event.url == '/stock') {
          this.PageTitle = '这里是列表页面';
        }
      });
  }

  ngOnInit() {

  }
}

